package com.isitandroid.coldfireteamapp;

import greendroid.app.GDActivity;
import greendroid.widget.ActionBarItem;
import greendroid.widget.ActionBarItem.Type;
import greendroid.widget.QuickAction;
import greendroid.widget.QuickActionBar;
import greendroid.widget.QuickActionWidget;
import greendroid.widget.QuickActionWidget.OnQuickActionClickListener;
import android.content.Intent;
import android.os.Bundle;
import android.os.Handler;
import android.util.Log;
import android.view.View;
import android.widget.ImageView;
import android.widget.RelativeLayout;
import android.widget.Toast;

public class ColdFireTeamAppActivity extends GDActivity  {
	
	// hello world 
	
	/**
	 * Splashscreen constants
	 */
	

	private Handler mHandler = new Handler();
	private SplashScreenThread splashTread;

	private RelativeLayout splashLayout;
	private RelativeLayout mainLayout;
	private ImageView splashLogo;
	
	private final int HOME = -1;	
	private final int LOCATE = 0;
	private final int REFRESH = 1;
	private final int SHARE = 2;

	
	private QuickActionWidget quickActions;
	
    /** Called when the activity is first created. */
    @Override
    public void onCreate(Bundle savedInstanceState) {
        super.onCreate(savedInstanceState);   
        setActionBarContentView(R.layout.main);
		splashLayout = (RelativeLayout) findViewById(R.id.spalsh);
		mainLayout = (RelativeLayout) findViewById(R.id.home);
		splashLogo = (ImageView) findViewById(R.id.spalsh_logo);
		mainLayout.setVisibility(View.GONE);
		///
		splashTread = new SplashScreenThread(mHandler, splashLogo, splashLayout, mainLayout);
		splashTread.start();
		
        Tools.initTheToast(this);
        initActionBar();
        initQuickActionBar();
getActionBar().setTitle("test"); 
    }
    
	
    private void initActionBar() {
    	addActionBarItem(Type.Locate, LOCATE);
    	addActionBarItem(Type.Refresh, REFRESH);
    	addActionBarItem(Type.Share, SHARE);
    	}
    
    
    @Override
    public boolean onHandleActionBarItemClick(ActionBarItem item, int position) {
    	switch (item.getItemId()) {
        case HOME:
        	Tools.showTheToast("hello world this ");

            break;  
    	case LOCATE:
        	Tools.showTheToast("hello world hello world hello world hello world hello world hello world hello world \n hello world hello world ");
//        	Intent testInent = new Intent(this, TestActivity.class);
//        	startActivity(testInent);
            break;
     
        case REFRESH:
        	Intent flipIntent = new Intent(this, FlipperActivity.class);
        	startActivity(flipIntent);
        	
  
            break;
     
        case SHARE:
        	quickActions.show(item.getItemView());
        	
        	setProgressBarIndeterminate(true);
            break;
        default:
            return super.onHandleActionBarItemClick(item, position);
        }
     
        return true;
    }
    
    
    
    private void initQuickActionBar() {
        quickActions = new QuickActionBar(this);
        quickActions.addQuickAction(new QuickAction(this, R.drawable.facebook,
            "Facebook"));
        quickActions.addQuickAction(new QuickAction(this, R.drawable.twitter, "Twitter"));
        quickActions.addQuickAction(new QuickAction(this, R.drawable.blogblogs, "Email"));
        quickActions.setOnQuickActionClickListener(new OnQuickActionClickListener() {
            public void onQuickActionClicked(QuickActionWidget widget,
                int position) {
             Toast.makeText(ColdFireTeamAppActivity.this,
             "Item " + position + " clicked", Toast.LENGTH_SHORT)
             .show();
            }
        });
        }
    
}